/*
 * Copyright (c) Soon.Liao 2024. All rights reserved.
 * @Author: soon.liao
 * @Date: 2024-11-24 19:03:03
 * @LastEditors: soon.liao
 * @LastEditTime: 2024-11-28 23:29:45
 * @FilePath: /near_link_sdk/applications/sample/wifi-iot/app/rgb_controller/rgb_master.c
 * @Description: Create Date : 2024
 * NA
 */

#include <stdio.h>
#include <unistd.h>

#include "ohos_init.h"
#include "cmsis_os2.h"
#include "soc_osal.h"

#include "i2c_init.h"
#include "wifi_connect.h"
#include "radar_control.h"
// #include "radar_control.h"
#if defined(CONFIG_SAMPLE_SUPPORT_SLE_RGB_MASTER_SERVER)
#include "paj7620u2_entry.h"
#elif defined(CONFIG_SAMPLE_SUPPORT_SLE_RGB_MASTER_CLIENT)
#include "fast_led_entry.h"
#endif

#define RGB_MASTER_TASK_PRIO 24
#define RGB_MASTER_TASK_STACK_SIZE 0x1000

static void rgb_master_task(void)
{
    osal_printk("[rgb_master]rgb_master_task start \r\n");
    i2c1_init_pin();
    ssd1306_device_init();
    radar_get_status_from_kv();
    wifi_connect_entry();
#if defined(CONFIG_SAMPLE_SUPPORT_SLE_RGB_MASTER_SERVER)
    paj7620u2_entry();
#elif defined(CONFIG_SAMPLE_SUPPORT_SLE_RGB_MASTER_CLIENT)
    fast_led_entry();
#endif
    // radar_task_create();
}

void rgb_master_entry(void)
{
    osThreadAttr_t attr;
    attr.name = "rgb_master_task";
    attr.attr_bits = 0U;
    attr.cb_mem = NULL;
    attr.cb_size = 0U;
    attr.stack_mem = NULL;
    attr.stack_size = RGB_MASTER_TASK_STACK_SIZE;
    attr.priority = RGB_MASTER_TASK_PRIO;
    osal_printk("[rgb_master]rgb_master_task start \r\n");
    if (osThreadNew((osThreadFunc_t)rgb_master_task, NULL, &attr) == NULL) {
        osal_printk("[rgb_master] Failed to create rgb_master_task!\n");
    }
}

SYS_RUN(rgb_master_entry);